#pragma warning(disable:4996)

#include <stdio.h>
#include <memory.h>
#include <string.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

class Method1
{
	struct Node
	{
		bool used;
		Node* next[10];
		Node()
		{
			used = false;
			memset(next, NULL, sizeof(next));
		}
	};

	void destory(Node* node)
	{
		if (node == NULL)
			return;

		for (int i = 0; i < 10; i++)
		{
			destory(node->next[i]);
		}
		delete node;
	}
public:
	void run()
	{
		int t;
		scanf("%d", &t);	
		while (t--)
		{
			int n;
			bool ok = true;
			scanf("%d", &n);
			Node* root = new Node();
			while (n--)
			{
				char str[11];
				scanf("%s", str);
				if (ok)
				{
					Node* p = root;
					int len = strlen(str);
					for (int i = 0; i < len; i++)
					{
						if (p->next[str[i] - '0'] != NULL)
						{
							p = p->next[str[i] - '0'];
							if (p->used)
								ok = false;
						}
						else
						{
							p = p->next[str[i] - '0'] = new Node();
						}
						if (i == len - 1)
						{
							p->used = true;
							for (int i = 0; i < 10; i++)
							{
								if (p->next[i] != NULL)
								{
									ok = false;
									break;
								}
							}
						}
					}
				}
			}
			destory(root);
			if (ok)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
};

class Method2
{
public:
	void run()
	{
		int t;
		scanf("%d", &t);
		while (t--)
		{
			int n;
			scanf("%d", &n);
			vector<string> list;
			while (n--)
			{
				char line[11];
				scanf("%s", line);
				list.push_back(line);
			}
			sort(list.begin(), list.end());

			bool ok = true;
			for (int i = 1; i < list.size(); i++)
			{
				if (list[i].find(list[i-1]) == 0)
				{
					ok = false;
					break;
				}
			}
			if (ok)
				printf("YES\n");
			else
				printf("NO\n");
		}
	}
};

int main()
{
	Method2* m = new Method2();
	m->run();
	return 0;
}